package com.xy.biz.xd.domain.converter;

import com.xy.biz.xd.domain.bo.DocumentFlowBorrowAndPrintAndDropBO;
import com.xy.biz.xd.domain.bo.DocumentFlowNewAndModifyBO;
import com.xy.biz.xd.domain.po.DocumentFlowNewAndModifyPO;
import com.xy.biz.xd.domain.req.*;
import com.xy.biz.xd.domain.resp.GetDocumentFlowNewResponse;
import com.xy.tool.util.BeanUtilsEx;

import java.util.Collection;
import java.util.List;

/**
 *
 *
 * @author wcs
 * @date 2021-2-26
 */
public class DocumentFlowBorrowAndPrintAndDropConverter {

    public static DocumentFlowNewAndModifyPO toPO(DocumentFlowNewAndModifyBO source) {
        return BeanUtilsEx.copyProperties(source, () -> new DocumentFlowNewAndModifyPO(), true);
    }

    public static List<DocumentFlowNewAndModifyPO> toPO(Collection<DocumentFlowNewAndModifyBO> source) {
        return BeanUtilsEx.copyPropertiesForNewList(source, () -> new DocumentFlowNewAndModifyPO(), true);
    }

    public static DocumentFlowNewAndModifyBO fromPO(DocumentFlowNewAndModifyPO source) {
        return BeanUtilsEx.copyProperties(source, () -> new DocumentFlowNewAndModifyBO());
    }

    public static List<DocumentFlowNewAndModifyBO> fromPO(Collection<DocumentFlowNewAndModifyPO> source) {
        return BeanUtilsEx.copyPropertiesForNewList(source, () -> new DocumentFlowNewAndModifyBO());
    }

    public static DocumentFlowNewAndModifyBO toBO(SaveDocumentFlowNewRequest source) {
        return BeanUtilsEx.copyProperties(source, () -> new DocumentFlowNewAndModifyBO(), true);
    }

    public static List<DocumentFlowNewAndModifyBO> toBO(Collection<SaveDocumentFlowNewRequest> source) {
        return BeanUtilsEx.copyPropertiesForNewList(source, () -> new DocumentFlowNewAndModifyBO(), true);
    }

    public static DocumentFlowBorrowAndPrintAndDropBO toBO(ApplyDocumentFlowBorrowRequest source) {
        return BeanUtilsEx.copyProperties(source, () -> new DocumentFlowBorrowAndPrintAndDropBO(), true);
    }

    public static DocumentFlowBorrowAndPrintAndDropBO toBO(ApplyDocumentFlowPrintRequest source) {
        return BeanUtilsEx.copyProperties(source, () -> new DocumentFlowBorrowAndPrintAndDropBO(), true);
    }

    public static List<DocumentFlowBorrowAndPrintAndDropBO> toBOList(ApplyDocumentFlowPrintAndBorrowAndDropRequest source) {
        return BeanUtilsEx.copyPropertiesForNewList(source.getDocumentFlowInfoList(), () -> new DocumentFlowBorrowAndPrintAndDropBO(), (src, tar) -> {
            tar.setDocumentCode(src.getDocumentCode());
            tar.setDocumentName(src.getDocumentName());
            tar.setDocumentVersion(src.getDocumentVersion());
            tar.setDocumentManagerUserId(source.getNextHandleUserId());
            tar.setContentAuditUserId(source.getNextHandleUserId());
            tar.setReason(source.getReason());
            tar.setUrgent(source.getUrgent());
            tar.setBatchType(source.getBatchType());
        });
    }

    public static DocumentFlowBorrowAndPrintAndDropBO toBO(ApplyDocumentFlowDropRequest source) {
        return BeanUtilsEx.copyProperties(source, () -> new DocumentFlowBorrowAndPrintAndDropBO(), true);
    }

    public static GetDocumentFlowNewResponse toResponse(DocumentFlowNewAndModifyBO source) {
        return BeanUtilsEx.copyProperties(source, () -> new GetDocumentFlowNewResponse());
    }

    public static List<GetDocumentFlowNewResponse> toResponse(Collection<DocumentFlowNewAndModifyBO> source) {
        return BeanUtilsEx.copyPropertiesForNewList(source, () -> new GetDocumentFlowNewResponse());
    }


}
